//
//  CLFormData.m
//  togetherLBS
//
//  Created by louis on 15/8/13.
//  Copyright (c) 2015年 celi. All rights reserved.
//

#import "CLFormData.h"

@implementation CLFormData
+ (instancetype)data
{
    return [[self alloc] init];
}
@end

@implementation CLJPEGFormData

+ (instancetype)dataWithImage:(UIImage *)image
{
    CLJPEGFormData *formData = [[self alloc] init];
    formData.image = image;
    return formData;
}

- (instancetype)init
{
    if (self = [super init]) {
        // 文件类型
        self.mimeType = @"image/jpeg";
        // 照片上传到服务器后的文件命名
        // 必须要有.jpg后缀名，TORO服务器根据后缀进行判断为哪种文件
        self.filename = @"head_icon.jpg";
    }
    return self;
}

- (void)setImage:(UIImage *)image
{
    _image = image;
    self.data = UIImageJPEGRepresentation(image, 0.5);
}
@end

@implementation CLVoiceFormData
-(instancetype)init
{
    if (self = [super init]) {
        self.mimeType = @"audio/basic";
        self.filename = @"record.amr";
    }
    return self;
}

- (void)setVoiceFilePath:(NSString *)voiceFilePath
{
    _voiceFilePath = voiceFilePath;
    
    self.data = [NSData dataWithContentsOfFile:voiceFilePath];
}
@end
